//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#include <stdlib.h>

#define INT_SIZE_LENGTH     32
#define I64_SIZE_LENGTH     64

long __cdecl _wtol(const wchar_t * nptr)
{
    char astring[INT_SIZE_LENGTH + 1];

    if (!nptr) return 0;
    _wcstostr(astring, nptr);

    return (atol(astring));
}

/***
*__int64 _wtoi64(wchar_t *nptr) - Convert wide string to __int64
*
*Purpose:
*       Converts wide string pointed to by nptr to binary.
*       Overflow is not detected.  Because of this, we can just use
*       _atoi64().
*
*Entry:
*       nptr = ptr to wide string to convert
*
*Exit:
*       return __int64 value of the string
*
*Exceptions:
*       None - overflow is not detected.
*
*******************************************************************************/

__int64 __cdecl _wtoi64(
    const wchar_t *nptr
    )
{
    char astring[I64_SIZE_LENGTH + 1];

    if (!nptr) return 0;
    _wcstostr(astring, nptr);

    return (_atoi64(astring));
}
